package 矩阵.螺旋矩阵;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @className: lxjz
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-04 11:48
 **/
public class lxjz {

    public static void main(String[] args) {

    }

    public static List<Integer> spiralOrder(int[][] matrix) {
        int x = 0;
        int y = 0;
        int count = 0;
        int m = matrix.length;
        int n = matrix[x].length;
        List<Integer> result = new ArrayList();
        while(count != m*n){
            if(x == m){
                y--;
            }
            if(x == 0){
                x++;
            }
            if(y == n){
                x++;
            }
            if(y == 0){
                y++;
            }
            result.add( matrix[x][y]);
            y++;
            count++;
        }
        return result;
    }
}
